-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support non-integer exponents to handle the result of square root #3439
Conversation
This has been sort of test-implemented in Dymola (replacing the previous "Support computing them without having a syntax for generating them"), and seems to work and be straightforward to implement. |
In System Modeler we implemented the syntax I'm not expecting that users will encounter the underlying syntax frequently, as they are generally exposed only to units nicely typeset for display purposes. For this reason, I find it more important to have consistent treatment of integers and rationals, than now introducing additional characters in the syntax for hinting that numbers in unit expressions are exponents. |
We also had some other variant originally in Dymola.
I did not consider that variant. I'm not sure how "-" is simpler for parsing than "^" (to me a previously unused character seems simpler to parse). I assume that is also the square root of meter, so I see two problems:
Or did you mean "m+(1/2)" for this case? That would be more understandable (require sign and then write the fraction in parenthesis), but I don't find it nice. |
Oh, the minus sign was just there to show where the sign of a negative rational number is placed, similar to
|
So, corresponding to the second to last in my list. |
Yes, but with clarification of where the sign goes. |
To discuss:
|
This touches the question of non-reduced rationals. As I see it, one could separately disallow 1 in the denominator without disallowing other non-reduced rationals, as it is a much more easily checked requirement to not have 1 in the denominator than checking for common factors in general. What about the exponent 0? What about the exponent 1? I think we should strive for consistency in allowing redundant ways to express unit factors…
I see two orthogonal questions here:
(I wish the In case you do a poll in the meeting today, please consider me in favor of |
Poll: (currently |
Allow non-simplified fractions, but still prohibit m(4/2).
Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the possibly…possibly being there already before, it can also be fixed separately.
One problem with defining the unit for sqrt(x) as proposed in #2127 is that sqrt(1m) is 1m^(1/2).
Obviously in most cases sqrt will return a normal unit, e.g. sqrt(4m^2) is 2m, so we should not consider this as a common case.
The proposed syntax for that is unit="m^(1/2)".
There are multiple options - some of the ones I considered and rejected:
An additional possibility would be also allow the symbol for integers. I can see this in the future, but don't think it is needed at the moment - and by being more restrictive the mapping back from internal unit (including inferred ones) to the unit-syntax is more restricted to ensure that there is no change unless needed. (A similar reason explains why the fraction must be simplified.)